package com.sjzd.meeting.controller;

import com.sjzd.meeting.pojo.MeetingType;
import com.sjzd.meeting.service.IMeetingTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
@RequestMapping("/meetingType")
public class MeetingTypeController {

    @Autowired
    private IMeetingTypeService meetingTypeService;

    @GetMapping("/findAll")
    public String findAll(@RequestParam(name = "target") String target,
                          @RequestParam(name="uid",defaultValue = "")String uid, Model model) {
        List<MeetingType> meetingTypes = meetingTypeService.findAll();
        model.addAttribute("meetingTypes", meetingTypes);
        if (!"".equals(uid)) {
            model.addAttribute("uid", Integer.parseInt(uid));
        }
        return "weixin/"+target + " :: mtypes";
    }
}
